<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>系统登录页面</title>
    <link rel="stylesheet" href="/public/admin/css/layui.css"  media="all">
    <script src="/public/index/css/jquery.min.js"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>管理员登录</legend>
</fieldset>
<div style="width: 500px; margin: auto;">
<form class="layui-form" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="adminname" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即登录</button>
        </div>
    </div>
</form>
</div>
<script src="/public/admin/layui.all.js" charset="utf-8"></script>
<!-- 获取cookie脚本 -->
<script src="/public/index/css/jquery.cookie.js"></script>
<script>
    if(!$.cookie('adminname')){
        layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function(data){
                //layer.msg(JSON.stringify(data.field));
                var name=data.field.adminname;
                var pass=data.field.password;
                $.post("/admin_login_do",{name:name,pass:pass},function(data){
                    if(data==200){
                        layer.msg("登录成功");
                        location.href="/admin_index";
                    }else {
                        layer.msg(data);
                    }
                });
                return false;
            });
        });
    }else {
        location.href="/admin_index";
    }

</script>
</body>
</html>